﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace WcfTwitterChatService
{

    [ServiceContract]
    
    public interface ITwitterChatService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "Channels/All")]
        IEnumerable<ChannelDTO> GetAllChannels();

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "GetNewMessages/{channel}")]
        IEnumerable<MessageDTO> GetNewMessages(string channel);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "GetAllMessages/{channel}")]
        IEnumerable<MessageDTO> GetAllMessagesInChannel(string channel);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "Channels/CreateChannel/{name}")]
        void CreateNewChannel(string name);

        //[OperationContract]
        //[WebGet(UriTemplate = "/post?test={test}",
        //        RequestFormat = WebMessageFormat.Json,
        //        ResponseFormat = WebMessageFormat.Json,
        //        BodyStyle = WebMessageBodyStyle.Wrapped)]
        //void PostMessageTest(string test);

        [OperationContract]
        [WebInvoke(Method = "POST",
                    UriTemplate = "/PostMessage",
                    BodyStyle = WebMessageBodyStyle.WrappedRequest,
                   RequestFormat = WebMessageFormat.Json,
                   ResponseFormat = WebMessageFormat.Json)]
        void PostMessage(Msg msg);

    }

    [DataContract]
    public class Msg
    {
        [DataMember]
        public string Text { get; set; }

        [DataMember]
        public string Channel { get; set; }

        [DataMember]
        public string PostingDate { get; set; }
    }
}
